package com.atguigu.resp;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class ResultData2<T> {
    private String code;
    private String message;
    private T data;
    private long timestamp;

    private String traceId;

    public ResultData2() {
        this.timestamp=System.currentTimeMillis();
    }

    public static <T>ResultData2<T>success(T data){
        ResultData2<T> resultData2 = new ResultData2<>();
        resultData2.setCode(ReturnCodeEnum2.RC200.getCode());
        resultData2.setMessage(ReturnCodeEnum2.RC200.getMessage());
        resultData2.setData(data);
        return resultData2;
    }

    public static <T>ResultData2<T>fail(String code,String message) {
        ResultData2<T> resultData2 = new ResultData2<>();
        resultData2.setCode(code);
        resultData2.setMessage(message);
        return resultData2;
    }
}
